/*
 * @Author: your name
 * @Date: 2020-02-29 18:04:05
 * @LastEditors: komons
 * @LastEditTime: 2020-02-29 18:25:50
 * @Description: 
 * @FilePath: \form-builderc:\Komons\学习\visualization\src\utils\storageUtils.js
 */
export function saveToLocalStorage(name, value) {
    if (localStorage) {
      try {
        value = JSON.stringify(value);
      } catch (error) {
      }
      localStorage.setItem(name, value);
    }
  }
  
  export function getToLocalstorage(name) {
    if(localStorage) {
      let res = localStorage.getItem(name);;
      try {
        res = JSON.parse(res);
      } catch(error) {
      }
      return res;
    }
  }
  
  export function saveToSessionStorage(name, value) {
    if (sessionStorage) {
      try {
        value = JSON.stringify(value);
      } catch (error) {
      }
      sessionStorage.setItem(name, value);
    }
  }
  
  export function getToSessionStorage(name) {
    if(sessionStorage) {
      let res = sessionStorage.getItem(name);;
      try {
        res = JSON.parse(res);
      } catch(error) {
      }
      return res;
    }
  }